package xio.ccf_201709;

import java.util.Scanner;

/**
 * 201709-5 除法 90分 超时。。
 * Created by ywb47 on 2017/10/23.
 */
public class Division {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        //构造树状数组
        TreeArray treeArray = new TreeArray(n);
        long[] src = new long[n+1];
        for (int i = 1; i <= n; i++) {
            src[i]  = sc.nextInt();
            treeArray.put(i,src[i]);
        }

        for (int i = 0; i < m; i++) {
            int opt = sc.nextInt();
            if (opt == 2){  //操作2 求和
                int s = sc.nextInt();
                int e = sc.nextInt();
                if (s == e){
                    System.out.print(src[s]+"\n");
                    continue;
                }
                System.out.printf(treeArray.sum(s,e)+"\n");
            }else if (opt == 1){  //操作1
                int s = sc.nextInt();
                int e = sc.nextInt();
                int v = sc.nextInt();
                if (v == 1) continue; //除数为1时 跳过
                for (int j = s; j <= e; j++) {
                    if (src[j] >= v && src[j] % v == 0){
                        treeArray.put(j,src[j] / v - src[j]);
                        src[j] /= v;
                    }
                }
            }
        }
    }


    //树状数组
    static class TreeArray{
        int length;
        long[] tree;

        public TreeArray(int length ) {
            this.length = length;
            this.tree = new long[length+1];
        }

        void put(int index,long value){
            while(index <= length){
                tree[index] += value;
                index += lowBit(index);
            }
        }

        long sum1To(int index){
            long sum = 0;
            while (index !=0){
                sum += tree[index];
                index -= lowBit(index);
            }
            return sum;
        }

        long sum(int start,int end){
           return sum1To(end) - sum1To(start-1);
        }

         long lowBit(long k){
            return k & (-k);
        }
    }


}
